/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.myBook.slayer.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.myBook.slayer.model.MyBook;
import com.myBook.slayer.model.MyBookModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the MyBook service. Represents a row in the &quot;sp_MyBook&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.myBook.slayer.model.MyBookModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link MyBookImpl}.
 * </p>
 *
 * @author meenu
 * @see MyBookImpl
 * @see com.myBook.slayer.model.MyBook
 * @see com.myBook.slayer.model.MyBookModel
 * @generated
 */
public class MyBookModelImpl extends BaseModelImpl<MyBook>
	implements MyBookModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a my book model instance should use the {@link com.myBook.slayer.model.MyBook} interface instead.
	 */
	public static final String TABLE_NAME = "sp_MyBook";
	public static final Object[][] TABLE_COLUMNS = {
			{ "bookId", Types.BIGINT },
			{ "bookTitle", Types.VARCHAR },
			{ "author", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table sp_MyBook (bookId LONG not null primary key,bookTitle VARCHAR(75) null,author VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table sp_MyBook";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.myBook.slayer.model.MyBook"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.myBook.slayer.model.MyBook"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.myBook.slayer.model.MyBook"),
			true);
	public static long BOOKTITLE_COLUMN_BITMASK = 1L;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.myBook.slayer.model.MyBook"));

	public MyBookModelImpl() {
	}

	public long getPrimaryKey() {
		return _bookId;
	}

	public void setPrimaryKey(long primaryKey) {
		setBookId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_bookId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return MyBook.class;
	}

	public String getModelClassName() {
		return MyBook.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("bookId", getBookId());
		attributes.put("bookTitle", getBookTitle());
		attributes.put("author", getAuthor());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long bookId = (Long)attributes.get("bookId");

		if (bookId != null) {
			setBookId(bookId);
		}

		String bookTitle = (String)attributes.get("bookTitle");

		if (bookTitle != null) {
			setBookTitle(bookTitle);
		}

		String author = (String)attributes.get("author");

		if (author != null) {
			setAuthor(author);
		}
	}

	public long getBookId() {
		return _bookId;
	}

	public void setBookId(long bookId) {
		_bookId = bookId;
	}

	public String getBookTitle() {
		if (_bookTitle == null) {
			return StringPool.BLANK;
		}
		else {
			return _bookTitle;
		}
	}

	public void setBookTitle(String bookTitle) {
		_columnBitmask |= BOOKTITLE_COLUMN_BITMASK;

		if (_originalBookTitle == null) {
			_originalBookTitle = _bookTitle;
		}

		_bookTitle = bookTitle;
	}

	public String getOriginalBookTitle() {
		return GetterUtil.getString(_originalBookTitle);
	}

	public String getAuthor() {
		if (_author == null) {
			return StringPool.BLANK;
		}
		else {
			return _author;
		}
	}

	public void setAuthor(String author) {
		_author = author;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			MyBook.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public MyBook toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (MyBook)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		MyBookImpl myBookImpl = new MyBookImpl();

		myBookImpl.setBookId(getBookId());
		myBookImpl.setBookTitle(getBookTitle());
		myBookImpl.setAuthor(getAuthor());

		myBookImpl.resetOriginalValues();

		return myBookImpl;
	}

	public int compareTo(MyBook myBook) {
		long primaryKey = myBook.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		MyBook myBook = null;

		try {
			myBook = (MyBook)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = myBook.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		MyBookModelImpl myBookModelImpl = this;

		myBookModelImpl._originalBookTitle = myBookModelImpl._bookTitle;

		myBookModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<MyBook> toCacheModel() {
		MyBookCacheModel myBookCacheModel = new MyBookCacheModel();

		myBookCacheModel.bookId = getBookId();

		myBookCacheModel.bookTitle = getBookTitle();

		String bookTitle = myBookCacheModel.bookTitle;

		if ((bookTitle != null) && (bookTitle.length() == 0)) {
			myBookCacheModel.bookTitle = null;
		}

		myBookCacheModel.author = getAuthor();

		String author = myBookCacheModel.author;

		if ((author != null) && (author.length() == 0)) {
			myBookCacheModel.author = null;
		}

		return myBookCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(7);

		sb.append("{bookId=");
		sb.append(getBookId());
		sb.append(", bookTitle=");
		sb.append(getBookTitle());
		sb.append(", author=");
		sb.append(getAuthor());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(13);

		sb.append("<model><model-name>");
		sb.append("com.myBook.slayer.model.MyBook");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>bookId</column-name><column-value><![CDATA[");
		sb.append(getBookId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>bookTitle</column-name><column-value><![CDATA[");
		sb.append(getBookTitle());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>author</column-name><column-value><![CDATA[");
		sb.append(getAuthor());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = MyBook.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			MyBook.class
		};
	private long _bookId;
	private String _bookTitle;
	private String _originalBookTitle;
	private String _author;
	private long _columnBitmask;
	private MyBook _escapedModelProxy;
}